class CreateDisciplinas < ActiveRecord::Migration
  def self.up
    
    create_table :disciplinas do |t|
      t.references :usuario
      t.references :curso
      t.string :descricao, :limit => 100, :null => false
      t.string :ementa, :limit => 100, :null => false
      t.integer :carga_horaria, :limit => 3, :null => false

    end
     
    execute("alter table disciplinas add foreign key (usuario_id) references usuarios(id)")    
    execute("alter table disciplinas add foreign key (curso_id) references cursos(id)")
    add_index :disciplinas, :descricao, :unique => true
    end

  def self.down
    drop_table :disciplinas
  end
end


